#ifndef san_h
#define san_h

#define MAX_SAN_LEN 12

#include <move.h>
#include <stdio.h>


// forward declarations
struct position_t;
struct game_t;

/*
 * Convert a move to algebraic notation.
 *
 * buf must be a preallocated array with enough space (a maximum of 6
 * characters including the terminating null will be used). Returns a
 * pointer to buf.
 */
char* move_to_string(move_t m, char* buf);


/*
 * Decode the move from algebraic notation.
 *
 * In case of success (well formed string) returns 1 and stores the
 * move in *m. In case of failure returns 0.
 */
int move_from_string(const char* buf, move_t* m);


/*
 * Convert a move to standard algebraic notation.
 *
 * m must be a legal move for pos. buf must be a preallocated array
 * with enough space (a maximum of SAN_MAX_LEN including the
 * terminating null will be used). Returns a pointer to buf.
 */
char* move_to_san_string(move_t m,
			 const struct position_t* pos,
			 char* buf);

/*
 * Decode the move from standard algebraic notation.
 *
 * In case of success (well formed string and non ambiguous) returns 1
 * and stores the move in *m. In case of failure returns 0.
 */
int move_from_san_string(const char* buf,
			 const struct position_t* pos,
			 move_t* m);

/*
 * Convert a sequence of moves to standard algebraic notation.
 *
 * The separator string is included between each pair of adjacent
 * moves. The sequence of moved must be a legal when applied to
 * game. buf must be a preallocated array with enough space (the
 * maximum number of characters used if given by SAN_MAX_LEN - 1 per
 * move plus the separator strings, plus the terminating
 * null). Returns a pointer to buf.
 */
char* moves_to_san_string(const move_t* moves,
			  int nmoves,
			  const char* separator,
			  const struct game_t* game,
			  char* buf);

#endif  // san_h
